
#pragma once

namespace my_riterator
{
    template<class Iterator, class Ref, class Ptr>
    struct __reverse_iterator
    {
        typedef __reverse_iterator<Iterator, Ref, Ptr> reverse_iterator;
        
        Iterator _cur;

        __reverse_iterator(Iterator it)
            :_cur(it)
        {}

        __reverse_iterator(const reverse_iterator& it)
            :_cur(it._cur)
        {}
        
        reverse_iterator& operator++()
        {
            -- _cur;
            return *this;
        }
        reverse_iterator& operator--()
        {
            ++ _cur;
            return *this;
        }
        reverse_iterator operator++(int)
        {
            reverse_iterator tmp(*this);
            -- _cur;

            return tmp;
        }
        reverse_iterator operator--(int)
        {
            reverse_iterator tmp(*this);
            ++ _cur;

            return tmp;
        }

        Ref operator*()
        {
            Iterator tmp = _cur;
            -- tmp;

            return *tmp;
        }

        Ptr operator->()
        {
            return &(operator*());
        }
        
        bool operator==(const reverse_iterator& it)
        {
            return _cur == it._cur;
        }
        bool operator!=(const reverse_iterator& it)
        {
            return _cur != it._cur;
        }

    };
}
